<?php if (! defined('IN_SCRIPT') || ! defined('ADMIN_MODE')) { die('Access Denied!'); } ?>

<h2 style="text-align: center;">Список доступных трекеров</h2>
<table style="width: 80%; margin: 0 auto;">
    <thead>
    <tr>
        <th style="width: 2%;">ID</th>
        <th style="width: 25%;">Название трекера</th>
        <th style="width: 53%;">Описание</th>
        <th style="width: 9%;">Инвайты</th>
        <th style="width: 11%;">Статус</th>
    </tr>
    </thead>
    <tbody>
<?php
mysql::getInstance()->select('trackers', array('id',
                                               'name',
                                               'description',
                                               'inviteCount',
                                               'inviteStatus')
                                       , 100);
while($tracker = mysql::getInstance()->fetch()) {
?>
    <tr>
        <td><?php echo $tracker['id']; ?></td>
        <td><a href="index.php?page=view_tracker&amp;id=<?php echo $tracker['id']; ?>"><?php echo $tracker['name']; ?></a></td>
        <td><?php echo cropString($tracker['description'], 70); ?></td>
        <td style="text-align: center;">
            <a href="#" style="text-decoration: none;" 
                        onclick="increaseInviteCount(<?php echo $tracker['id']; ?>, 1)">
                        <b><span style="color: green;">[+]</span></b>
            </a> 
            <span id="trac<?php echo $tracker['id']; ?>"><?php echo $tracker['inviteCount']; ?></span> 
            <a href="#" style="text-decoration: none;"
                        onclick="decreaseInviteCount(<?php echo $tracker['id']; ?>, 1)">
                        <b><span style="color:red;">[-]</span></b>
            </a>
        </td>
        <?php if ($tracker['inviteStatus'] == INV_STATUS_CLOSED) {
            $inviteStatus = 'Закрыты';
        } elseif ($tracker['inviteStatus'] == INV_STATUS_OPEN) {
            $inviteStatus = 'Открыты';
        } else {
            $inviteStatus = 'Неизвестно';
        } ?>
        <td><?php echo $inviteStatus; ?></td>
    </tr>
    </tbody>
    <?php
    }
    
    ?></table>